-
-
Notifications
You must be signed in to change notification settings - Fork 3k
add Darwin family systems handling for totalSystemMemory #24903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Darwin family systems handling for totalSystemMemory #24903
Conversation
41a5088
to
9492937
Compare
This doesn't matter too much since I'll get to it when I do #6389 anyway. But yes, it probably should.
I think just remove the dead |
469c895
to
243ced2
Compare
@alexrp Thanks for the review! If there are no more questions/comments left, I believe this PR is ready for merging |
Could this also apply to the rest of the Darwin family? (.driverkit, .ios, .macos, .tvos, .visionos, .watchos) |
@SeanTheGleaming Hi! Do you know if all of them support |
I do not know for sure, but based on this article and the fact that many apis like this are shared throughout Darwin, I would assume so. |
This is the case more often than not. I see no indication that this particular function would only work on macOS. |
243ced2
to
0ca339d
Compare
Thanks, added. @alexrp Is there any particular order for the |
No, the order doesn't particularly matter. |
* add macos handling for totalSystemMemory * fix return type cast for .freebsd in totalSystemMemory * add handling for the whole Darwin family in totalSystemMemory
Hi, I just started learing zig. I was trying to fetch total system memory on macOS and noticed that
totalSystemMemory
does not support it.This PR adds it.
I believe there are a few issues with
totalSystemMemory
for.freebsd
andstd.posix.sysctlbynameZ
, but I do not know what the correct approach to take heretotalSystemMemory
for.freebsd
returnsusize
instead ofu64
, I believe this should be fixedtotalSystemMemory
for.freebsd
does not handle all the errors fromstd.posix.sysctlbynameZ
.std.posix.sysctlbynameZ
never returnsNameTooLong
. So either we should change the return type, or, as @andrewrk did in 3640303 we should addname_len
handling. I did not find any mention ofENAMETOOLONG
in manpages for freebsd/posix. So I am having a hard time understanding which way is correct here.Just for the context I know that there were discussions in #16350 that resulted in the rollback of patches that already implemented this functionality before. Please let me know what should be done to meet contributing standards to avoid same fate as previous contributor 🙂
I am ready to provide patches for 1 and 2 in this PR or create separate one
Thanks!